#ifdef _DEBUG
	#pragma comment (lib, "sfml-main-d.lib")
	#pragma comment (lib, "sfml-network-s-d.lib")
	#pragma comment (lib, "sfml-audio-s-d.lib")
	#pragma comment (lib, "sfml-graphics-s-d.lib")
	#pragma comment (lib, "sfml-window-s-d.lib")
	#pragma comment (lib, "sfml-system-s-d.lib")

	#pragma comment (lib, "thor-s-d.lib")

	#pragma comment (lib, "pugixml_d.lib")
	#pragma comment (lib, "luabind-s-d.lib")

	#pragma comment (lib, "SimpleRPG-d.lib")
	#pragma comment (lib, "Bind-d.lib")
	#pragma comment (lib, "MapLoader-d.lib")
#else
	#pragma comment (lib, "sfml-main.lib")
	#pragma comment (lib, "sfml-network-s.lib")
	#pragma comment (lib, "sfml-audio-s.lib")
	#pragma comment (lib, "sfml-graphics-s.lib")
	#pragma comment (lib, "sfml-window-s.lib")
	#pragma comment (lib, "sfml-system-s.lib")

	#pragma comment (lib, "thor-s.lib")

	#pragma comment (lib, "pugixml.lib")
	#pragma comment (lib, "luabind-s.lib")

	#pragma comment (lib, "SimpleRPG.lib")
	#pragma comment (lib, "Bind.lib")
	#pragma comment (lib, "MapLoader.lib")
#endif

	#pragma comment (lib, "Lua5.1.lib")
	#pragma comment (lib, "Lua51.lib")

// std Header
#include <iostream>
#include <sstream>

// Bind Header
#include <Bind/Bind.hpp>

// Eigene Header
#include "Application.hpp"

//#ifdef _DEBUG
#define _LUADEBUG
//#endif

int main(int argc, char* argv[])
{
	sl::LogManager->Insert("stdout", new sl::Logger());//("stdout.log"));
	sl::LogManager->Insert("application", new sl::/*Logger());/*/FileLogger("application.log"));
	sl::LogManager->Insert("error", new sl::FileLogger("error.log"));
#ifdef _LUADEBUG
	sl::LogManager->Insert("lua", new sl::Logger());
#else
	sl::LogManager->Insert("lua", new sl::FileLogger("lua.log"));
#endif
	sl::LogManager->Insert("luafunction", new sl::FileLogger("luafunction.log"));

	try {
		bind::Bind((*sl::Lua)());
	} catch(std::exception& e) {
		sl::Exception(e.what(), sl::ErrorCode::Bind);
		return sl::ErrorCode::Bind;
	}

#ifdef _DEBUG
	luabind::globals((*sl::Lua)())["DEBUG"] = true;
#else
	luabind::globals((*sl::Lua)())["DEBUG"] = false;
#endif

	sl::FolderManager->Insert("script", "Scripts/");
	sl::FolderManager->Insert("image", "Images/");
	sl::FolderManager->Insert("map", "Maps/");
	sl::FolderManager->Insert("tileset", "TileSets/");
	sl::FolderManager->Insert("shader", "Shader/");

	std::string scr = *sl::FolderManager->Get("script");
	sl::ScriptManager->Insert(scr + "init.lua");
	sl::ScriptManager->Insert(scr + "run.lua");
	sl::ScriptManager->Insert(scr + "input.lua");
	sl::ScriptManager->Insert(scr + "pause.lua");
	sl::ScriptManager->Insert(scr + "quit.lua");
	sl::ScriptManager->Insert(scr + "test.lua");
	sl::ScriptManager->Insert(scr + "anim.lua");

	Application app;
	sl::ErrorCode err = app();
	if (err != sl::ErrorCode::NothingSpecific)
	{
		sl::LogManager->Get("application")->Write(sl::LogType::Error, "Executed with ErrorCode " + sl::Convert(err) + " " + sl::ErrorCodeToString(err));
		std::cin.get();
		return err;
	}

	return 0;
}